<template>
  <view class="content">
    <swiper :indicator-dots="true" :autoplay="false" :duration="1000" :indicator-width="10"
      indicator-active-color="#fff">
      <swiper-item>
        <view class="img">
          <image src="../../static/bew.png" mode=""></image>
        </view>
        <view class="context">
          <view class="tit">
            右耳兔
          </view>
          <view class="desc">
       
          </view>
        </view>
      </swiper-item>
      <swiper-item>
        <view class="img">
          <image src="../../static/bew.png" mode=""></image>
        </view>
        <view class="context">
          <view class="tit">
             右耳兔
          </view>
          <view class="desc">
            
          </view>
        </view>
      </swiper-item>
      <swiper-item>
        <view class="img">
          <image src="../../static/bew.png" mode=""></image>
        </view>
        <view class="context">
          <view class="tit endTxt">
            欢迎使用
          </view>
          <view class="startBtn" @tap="goHome">
            进入应用
          </view>
        </view>
      </swiper-item>
    </swiper>
  </view>
</template>

<script >
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
			try {
				// var userInfo={"userId":"1","nickName":"admin"};
				// uni.setStorageSync('authInfo', JSON.stringify(userInfo));
				
				let token =uni.getStorageSync("token");
				if(token){
					uni.switchTab({
						url:"/pages/home/home"
					})
				}else{
					uni.redirectTo({
						url:"/pages/login/login"
					})
				}
				console.log("1"+authInfo)
			} catch (e) {
				console.log("error")
				// error
			}
			console.log("init")
		},
		methods: {
			goHome:function(){
				let token =uni.getStorageSync("token");
				if(token){
					uni.switchTab({
						url:"/pages/home/home"
					})
				}else{
					uni.redirectTo({
						url:"/pages/login/login"
					})
				}
			},
		}
	}

</script>

<style scoped>
  .content {
    width: 100%;
    height: 100vh;
  }

  swiper {
    height: 100%;
    height: 100vh;
  }

  swiper-item .img image {
    height: 450rpx;
  }

  swiper-item .img {
    position: fixed;
    top: 450rpx;
    left: 50%;
    transform: translateX(-50%);
  }

  .context {
    width: 100%;
    text-align: center;
    position: fixed;
    bottom: 180rpx;
    left: 50%;
    transform: translateX(-50%);
  }

  .tit {
    font-size: 60rpx;
    color: #ffff00;
    margin-bottom: 20rpx;
  }

  .endTxt {
    font-size: 60rpx;
    color: #ffffff;

  }

  .desc {
    font-size: 40rpx;
    color: #ffffff;
    margin-bottom: 20rpx;
  }

  swiper-item:nth-child(1) {
    height: 100%;
    background-color: rgb(25, 219, 204);
  }

  swiper-item:nth-child(2) {
    height: 100%;
    background-color: rgb(0, 206, 222);
  }

  swiper-item:nth-child(3) {
    height: 100%;
    background-color: rgb(146, 147, 240);
  }

  /* 这里无法兼容 需要分开写 */
  /* #ifdef MP-WEIXIN */
  ::v-deep .wx-swiper-dots {
    bottom: 100rpx !important;
  }

  ::v-deep .wx-swiper-dot-active {
    width: 50rpx;
    border-radius: 50rpx;
  }

  /* #endif */

  ::v-deep .uni-swiper-dots-horizontal {
    bottom: 100rpx !important;
  }

  .startBtn {
    width: 355rpx;
    line-height: 80rpx;
    text-align: center;
    font-size: 30rpx;
    color: #000000;
    background-color: rgba(255, 255, 255, 1);
    border-radius: 40rpx;
    margin: 20rpx auto;
    letter-spacing: 10rpx;
    margin-top: 60rpx;
  }
</style>